﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ZhiAo.CommonLibrary
{
    public static class DataRowExtend
    {

        public static string GetFieldValue(this DataRow row, string fieldName)
        {
            if (!row.Table.Columns.Contains(fieldName)) return "";
            if (row[fieldName] == DBNull.Value) return "";
            return row[fieldName].ToString().Trim();
        }

        public static string GetFieldValue(this DataRow row, string fieldName, string defaultValue)
        {
            string result = row.GetFieldValue(fieldName);
            if (result == "") result = defaultValue;
            return result;
        }
    }
}
